﻿@using Discussion.Core.Mvc
@using Discussion.Web.Services.UserManagement.Avatar
@inject Microsoft.AspNetCore.Hosting.IHostingEnvironment HostingEnvironment
@inject IAvatarUrlService AvatarUrlService
@inject Discussion.Core.Models.SiteSettings SiteSettings

@{
    var pageTitle = "dotnet club";
    var viewDataTitle = ViewData["Title"];
    if (null != viewDataTitle)
    {
        var title = (string) viewDataTitle;
        pageTitle =  $"{title} - {pageTitle}";
    }
    
    var pageKeyword = ViewData["Keyword"];
    if (null == pageKeyword)
    {
        pageKeyword = ".NET,.NET Core, .NET 跨平台, .NET 微服务, DevOps, 云原生, .NET 在线社区";
    }
    
    var pageDescription = ViewData["Description"];
    if (null == pageDescription)
    {
        pageDescription = "dotnet club 是中国 .NET 开发人员的聚集地，围绕 .NET 技术的问题解答与最佳实践展开讨论";
    }
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@pageTitle</title>
    <meta name="keywords" content="@pageKeyword" />
    <meta name="description" content="@pageDescription" />
    <link rel="shortcut icon" href="~/favicon/favicon.ico" />
    <link rel="icon" type="image/png" sizes="16x16" href="~/favicon/favicon-16x16.png">
    <link rel="icon" type="image/png" sizes="32x32" href="~/favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="96x96" href="~/favicon/favicon-96x96.png">
    <environment names="Development">
        <link rel="stylesheet" href="~/dist/packed-css-vendor.css" />
        <link rel="stylesheet" href="~/dist/packed-css.css" />
    </environment>
    <environment names="QA,Integration,Staging,Production">
        <link rel="stylesheet" href="~/dist/packed-css-vendor.min.css" asp-append-version="true" />
        <link rel="stylesheet" href="~/dist/packed-css.min.css" asp-append-version="true"/>
    </environment>
    @RenderSection("Head", required: false)
</head>
<body class="with-generic-nav">
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-navigation">
                    <span class="sr-only">菜单栏</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <div class="header-user pull-right hidden-sm hidden-md hidden-lg">
                    @if (Context.IsAuthenticated())
                    {
                        <div class="dropdown">
                            <div class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                <img src="@AvatarUrlService.GetAvatarUrl(Context.DiscussionUser())" class="avatar"/>
                                <span class="caret"></span>
                            </div>
                            <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                                <li class="username-item">你好，<span class="username" title="@Context.DiscussionUser().DisplayName">@Context.DiscussionUser().DisplayName</span></li>
                                <li role="separator" class="divider"></li>
                                <li>@Html.ActionLink("设置", "Settings", "User", null, new { @class = "user-settings-link" })</li>
                                <li>
                                    <form class="signout-form" asp-action="DoSignOut" asp-controller="Account" method="post">
                                        <button>注销</button>
                                    </form>
                                </li>
                            </ul>
                        </div>
                    }
                    else
                    {
                        if (SiteSettings.CanRegisterNewUsers())
                        {
                            @Html.ActionLink("注册", "Register", "Account", null, new {@class = "signin-link"})
                            <span>&nbsp;</span>
                        }
                        @Html.ActionLink("登录", "Signin", "Account", null, new {@class = "signin-link"})
                    }
                </div>
                <a class="navbar-brand" href="/">dotnet club</a>
            </div>
            <div id="main-navigation" class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="/">首页</a></li>
                    @if (!string.IsNullOrWhiteSpace(SiteSettings.HeaderLink1Text) && !string.IsNullOrWhiteSpace(SiteSettings.HeaderLink1Url))
                    {
                        <li><a href="@SiteSettings.HeaderLink1Url">@SiteSettings.HeaderLink1Text</a></li>
                    }                    
                    @if (!string.IsNullOrWhiteSpace(SiteSettings.HeaderLink2Text) && !string.IsNullOrWhiteSpace(SiteSettings.HeaderLink2Url))
                    {
                        <li><a href="@SiteSettings.HeaderLink2Url">@SiteSettings.HeaderLink2Text</a></li>
                    }                    
                    @if (!string.IsNullOrWhiteSpace(SiteSettings.HeaderLink3Text) && !string.IsNullOrWhiteSpace(SiteSettings.HeaderLink3Url))
                    {
                        <li><a href="@SiteSettings.HeaderLink3Url">@SiteSettings.HeaderLink3Text</a></li>
                    }                    
                    @if (!string.IsNullOrWhiteSpace(SiteSettings.HeaderLink4Text) && !string.IsNullOrWhiteSpace(SiteSettings.HeaderLink4Url))
                    {
                        <li><a href="@SiteSettings.HeaderLink4Url">@SiteSettings.HeaderLink4Text</a></li>
                    }
                </ul>
                <div class="header-user pull-right hidden-xs">
                    @if (Context.IsAuthenticated())
                    {
                        <div class="dropdown">
                            <div class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                <img src="@AvatarUrlService.GetAvatarUrl(Context.DiscussionUser())" class="avatar"/>
                                <span class="caret"></span>
                            </div>
                            <ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
                                <li class="username-item">你好，<span class="username" title="@Context.DiscussionUser().DisplayName">@Context.DiscussionUser().DisplayName</span></li>
                                <li role="separator" class="divider"></li>
                                <li>@Html.ActionLink("设置", "Settings", "User", null, new { @class = "user-settings-link" })</li>
                                <li>
                                    <form class="signout-form" asp-action="DoSignOut" asp-controller="Account" method="post">
                                        <button>注销</button>
                                    </form>
                                </li>
                            </ul>
                        </div>
                    }
                    else
                    {
                        if (SiteSettings.CanRegisterNewUsers())
                        {
                            @Html.ActionLink("注册", "Register", "Account", null, new {@class = "signin-link"})
                            <span>&nbsp;</span>
                        }
                        @Html.ActionLink("登录", "Signin", "Account", null, new {@class = "signin-link"})
                    }
                </div>
            </div>
        </div>
    </nav>

    @RenderSection("PreContent", required: false)

    <div class="container body-content">
        @RenderBody()
    </div>

    @RenderSection("PostContent", required: false)

<footer class="page-footer container">
    <p class="pull-left">@Html.Raw(SiteSettings.FooterNoticeLeft)</p>
    <p class="pull-right">@Html.Raw(SiteSettings.FooterNoticeRight)</p>
</footer>

<environment names="Development">
    <script src="~/dist/packed-js-vendor.js"></script>
    <script src="~/dist/packed-js.js"></script>
</environment>
<environment names="QA,Integration,Staging,Production">
    <script src="~/dist/packed-js-vendor.min.js" asp-append-version="true"></script>
    <script src="~/dist/packed-js.min.js" asp-append-version="true"></script>
</environment>
<script>
    @* 相关文档： https://docs.microsoft.com/en-us/aspnet/core/security/anti-request-forgery?view=aspnetcore-2.1  *@
    window.__RequestVerificationToken = '@Html.AntiForgeryTokenValue()';
</script>
    @RenderSection("Tail", required: false)
</body>
</html>
<!-- Environment: @HostingEnvironment.EnvironmentName -->